﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using System.IO;

namespace LingDong.ConfigProvider
{
    internal class GetTxtAsStringArray
    {
        internal static string[] Get(string file)
        {
            try
            {
                using (StreamReader sr = new StreamReader(file, Encoding.UTF8))
                {
                    List<string> resultList = new List<string>();
                    while (!sr.EndOfStream)
                    {
                        string line = sr.ReadLine().Replace("\\r", "\r").Replace("\\n", "\n");
                        resultList.Add(line);
                    }
                    return resultList.ToArray();
                }
            }
            catch (Exception ex)
            {
                Logger logger = LogManager.GetCurrentClassLogger();
                logger.Error("Cannot read target txt file: {0}, {1}", file, ex.Message);
                throw;
            }
        }
    }
}
